package com.qf.produce.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConfiguration {
    //声明队列
    @Bean
    public Queue queue1() {
        Queue queue1 = new Queue("queue1");
        //设置队列属性
        return queue1;
    }
    @Bean
    public Queue queue2() {
        Queue queue2 = new Queue("queue2");
        //设置队列属性
        return queue2;
    }
    //声明路由模式交换机
    @Bean
    public DirectExchange ex1() {
        return new DirectExchange("ex1");
    }
    //绑定队列
    @Bean
    public Binding bindingQueue1(Queue queue1, @Qualifier("ex1") DirectExchange ex1) {
        return BindingBuilder.bind(queue1).to(ex1).with("k1");
    }
    @Bean
    public Binding bindingQueue2(Queue queue2, @Qualifier("ex1")DirectExchange ex1) {
        return BindingBuilder.bind(queue2).to(ex1).with("k2");
    }
}
